package com.nxk.modules.core.web;

import com.nxk.modules.core.entity.SysOffice;
import com.nxk.modules.core.service.SysOfficeService;
import com.nxk.modules.exception.ResultEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/a/core/office")
public class SysOffIceController {



    @Autowired
    private SysOfficeService sysOfficeService;


    @RequiresPermissions("core:office:edit")
    @PutMapping("/save")
    public ResultEntity save(@Validated SysOffice sysOffice) {
        boolean flag = sysOfficeService.save(sysOffice);
        return flag ? ResultEntity.success(sysOfficeService.getById(sysOffice.getId())) : ResultEntity.fail();
    }

    @RequiresPermissions("core:office:view")
    @GetMapping("/get")
    public ResultEntity get(SysOffice sysOffice){
        SysOffice byId = sysOfficeService.getById(sysOffice);
        return ResultEntity.success(byId);
    }


}
